package algo_lignes_sites.ihm;

import algo_lignes_sites.data.Data_ls;
import algo_lignes_sites.ihm.couche.CoucheContrainteGeomNode;
import algo_lignes_sites.ihm.couche.CoucheForceDER;
import commons.data.I_Data;
import commons.data.I_Data.DataType;
import commons.drawing.couche.A_Couche;
import commons.drawing.couche.CoucheBasic;
import commons.drawing.couche.I_Couche;
import commons.ihm.A_PanelCartoTocTools;
import commons.ihm.A_PanelTOC;
import commons.ihm.ParametresAffichageCarto.TypeAffichage;
import commons.logs.Logger;
import commons.params_appli.ParamsAppli;
import java.util.ArrayList;

public class PanelTOC_ls extends A_PanelTOC {

	// C'est le PanelCartoTocTools pere qui renseigne cette donnée, qui contient toutes les couches
	private Data_ls data;

	private ArrayList<I_Couche> vAllCouche;
	
	// ensemble de tous les points (pour affichage topologique)
	private A_Couche coucheJunctionREF;
	private A_Couche coucheJunctionDER;

	// uniquement les nodes (postes, piquage, etc.)
	private A_Couche coucheNodeREF;
	private A_Couche coucheNodeDER;

	private A_Couche couchePathREF;
	private A_Couche couchePathDER;

	private A_Couche coucheForceDER;
	private A_Couche coucheSegmentDER;

	// segment REF
	private A_Couche coucheSegmentREF;
	private A_Couche coucheSegmentSOURCE; // pour debug : les données ne sont conservées qu'en mode debug

	// objets non generalisés
	private A_Couche coucheSegNonGeneralise;
	private A_Couche coucheNodeNonGeneralise;

	// infos sur les nodes en affichage Topologique
	private A_Couche coucheParamTopoNodeREF;
	private A_Couche coucheParamTopoNodeDER;
	
	private A_Couche coucheDimensionNodeREF;
	private A_Couche coucheDimensionNodeDER;
	
	private A_Couche coucheZoneInfluenceNodeREF;
	private A_Couche coucheZoneInfluenceNodeDER;

	private A_Couche coucheZone;


    public PanelTOC_ls(A_PanelCartoTocTools panel_Pere) {
		super(panel_Pere);
        initComponents();
		//this.panel_Pere = panel_Pere;
		majGrisageCheckBoxes();

		// On sélectionne par défaut le mode Carto
		tabbedPane.setSelectedIndex(0);
		panel_Pere.setTypeAffichage(TypeAffichage.PAPIER);
			
		if (!Logger.isDebugLevel()) {
			// Cette donnée n'est pas conservée en mode normal pour économiser de la mémoire
			//  -> on supprime la coche permettant de l'afficher
			cb_Topo_Segment_SOURCE.setVisible(false);
		}
    }
	

	@Override
	public void setData(I_Data dataToDisplay) {
		this.data = (Data_ls)dataToDisplay;

		// Pour optimiser la vitesse d'affichage de certaintes couches très chargées
		int nbJonctionMaxInView = ParamsAppli.getParam_i("Autogene.LS_NBMAX_JUNCTION_ON_MAP");

		// Construction des couches basées sur le Data
		couchePathREF     = new CoucheBasic("Path de référence", DataType.PATH_REF_LS, data, true);
		couchePathDER     = new CoucheBasic("Path généralisées", DataType.PATH_DER_LS, data, true);

		coucheNodeREF     = new CoucheBasic("Noeuds de référence", DataType.NODE_REF_LS, data, true, nbJonctionMaxInView);
		coucheNodeDER     = new CoucheBasic("Noeuds généralisés", DataType.NODE_DER_LS, data, true, nbJonctionMaxInView);

		coucheJunctionREF = new CoucheBasic("Jonctions de référence", DataType.JUNCTION_REF_LS, data, false, nbJonctionMaxInView);
		coucheJunctionDER = new CoucheBasic("Jonctions généralisées", DataType.JUNCTION_DER_LS, data, false, nbJonctionMaxInView);

		coucheForceDER    = new CoucheForceDER(data);
		coucheSegmentDER  = new CoucheBasic("Segments généralisées", DataType.SEGMENT_DER_LS, data);

		coucheSegmentREF    = new CoucheBasic("Segments de référence", DataType.SEGMENT_REF_LS, data);
		coucheSegmentSOURCE = new CoucheBasic("Segments de référence", DataType.SEGMENT_SOURCE_LS, data);

		coucheSegNonGeneralise = new CoucheBasic("Segments non généralisés", DataType.SEGMENT_NON_GENERALISE_LS, data);
		coucheNodeNonGeneralise = new CoucheBasic("Segments non généralisés", DataType.NODE_NON_GENERALISE_LS, data);


		coucheParamTopoNodeREF = new CoucheContrainteGeomNode(data, CoucheContrainteGeomNode.TypeContraineGeom.PARAM_TOPO, true);
		coucheParamTopoNodeDER = new CoucheContrainteGeomNode(data, CoucheContrainteGeomNode.TypeContraineGeom.PARAM_TOPO, false);
	
		coucheDimensionNodeREF = new CoucheContrainteGeomNode(data, CoucheContrainteGeomNode.TypeContraineGeom.DIMENSION, true);
		coucheDimensionNodeDER = new CoucheContrainteGeomNode(data, CoucheContrainteGeomNode.TypeContraineGeom.DIMENSION, false);
	
		coucheZoneInfluenceNodeREF = new CoucheContrainteGeomNode(data, CoucheContrainteGeomNode.TypeContraineGeom.ZONE_INFLUENCE, true);
		coucheZoneInfluenceNodeDER = new CoucheContrainteGeomNode(data, CoucheContrainteGeomNode.TypeContraineGeom.ZONE_INFLUENCE, false);

		coucheZone = new CoucheBasic("Zones encarts", DataType.ZONE, data);

		vAllCouche = new ArrayList<I_Couche>();
		vAllCouche.add(couchePathREF);
		vAllCouche.add(couchePathDER);
		vAllCouche.add(coucheNodeREF);
		vAllCouche.add(coucheNodeDER);
		vAllCouche.add(coucheJunctionREF);
		vAllCouche.add(coucheJunctionDER);
		vAllCouche.add(coucheForceDER);
		vAllCouche.add(coucheSegmentDER);
		vAllCouche.add(coucheSegmentREF);
		vAllCouche.add(coucheSegmentSOURCE);
		vAllCouche.add(coucheParamTopoNodeREF);
		vAllCouche.add(coucheParamTopoNodeDER);
		vAllCouche.add(coucheDimensionNodeREF);
		vAllCouche.add(coucheDimensionNodeDER);
		vAllCouche.add(coucheZoneInfluenceNodeREF);
		vAllCouche.add(coucheZoneInfluenceNodeDER);
		vAllCouche.add(coucheZone);
	}

	@Override
	public ArrayList<I_Couche> getAllCouches() {
		return vAllCouche;
	}

	@Override
	public ArrayList<I_Couche> getVisibleCouches() {
		ArrayList<I_Couche> vCouche = new ArrayList<I_Couche>(5);
		if (data == null) return vCouche;

		if (cb_Zone.isSelected())
			vCouche.add (coucheZone);
		
		if (tabbedPane.getSelectedIndex() == 0) { // ONGLET PAPIER
			panel_Pere.setTypeAffichage(TypeAffichage.PAPIER);
			
			if (cb_Papier_Data_REF.isSelected()) {
				if (cb_Papier_Lignes_REF.isSelected()) vCouche.add (couchePathREF);
				if (cb_Papier_Sites_REF.isSelected()) vCouche.add (coucheNodeREF);
			}

			if (cb_Papier_Data_DER.isSelected()) {
				if (cb_Papier_Lignes_DER.isSelected()) vCouche.add (couchePathDER);
				if (cb_Papier_Sites_DER.isSelected()) vCouche.add (coucheNodeDER);
			}
			
		} else if (tabbedPane.getSelectedIndex() == 1) { // ONGLET TOPO
			panel_Pere.setTypeAffichage(TypeAffichage.TOPO);

			if (cb_Topo_Data_REF.isSelected()) {
				if (cb_Topo_ZoneInfluenceNode_REF.isSelected()) vCouche.add (coucheZoneInfluenceNodeREF);
				if (cb_Topo_DimensionNode_REF.isSelected()) vCouche.add (coucheDimensionNodeREF);
				if (cb_Topo_ParamTopoNode_REF.isSelected()) vCouche.add (coucheParamTopoNodeREF);
				
				if (cb_Topo_Path_REF.isSelected()) vCouche.add (couchePathREF);
				if (cb_Topo_Segment_REF.isSelected()) vCouche.add (coucheSegmentREF);
				if (cb_Topo_Segment_SOURCE.isSelected()) vCouche.add (coucheSegmentSOURCE);
				if (cb_Topo_Junction_REF.isSelected()) vCouche.add (coucheJunctionREF);
			}

			if (cb_Topo_Data_DER.isSelected()) {
				if (cb_Topo_ZoneInfluenceNode_DER.isSelected()) vCouche.add (coucheZoneInfluenceNodeDER);
				if (cb_Topo_DimensionNode_DER.isSelected()) vCouche.add (coucheDimensionNodeDER);
				if (cb_Topo_ParamTopoNode_DER.isSelected()) vCouche.add (coucheParamTopoNodeDER);
				
				if (cb_Topo_ObjetsSupprimesDER.isSelected()) {
					vCouche.add (coucheSegNonGeneralise);
					vCouche.add (coucheNodeNonGeneralise);
				}
				
				if (cb_Topo_Path_DER.isSelected()) vCouche.add (couchePathDER);
				if (cb_Topo_Segment_DER.isSelected()) vCouche.add (coucheSegmentDER);
				if (cb_Topo_Junction_DER.isSelected()) vCouche.add (coucheJunctionDER);
				if (cb_Topo_Force_DER.isSelected()) vCouche.add (coucheForceDER);
			}
		} else {
			assert(false);
		}

		return vCouche;
	}

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        tabbedPane = new javax.swing.JTabbedPane();
        jPanel1 = new javax.swing.JPanel();
        cb_Papier_Data_DER = new javax.swing.JCheckBox();
        cb_Papier_Sites_DER = new javax.swing.JCheckBox();
        cb_Papier_Lignes_DER = new javax.swing.JCheckBox();
        cb_Papier_Data_REF = new javax.swing.JCheckBox();
        cb_Papier_Sites_REF = new javax.swing.JCheckBox();
        cb_Papier_Lignes_REF = new javax.swing.JCheckBox();
        btn_Papier_Switch = new javax.swing.JButton();
        jPanel3 = new javax.swing.JPanel();
        cb_Topo_Data_DER = new javax.swing.JCheckBox();
        cb_Topo_Data_REF = new javax.swing.JCheckBox();
        cb_Topo_Junction_DER = new javax.swing.JCheckBox();
        cb_Topo_Path_DER = new javax.swing.JCheckBox();
        cb_Topo_Junction_REF = new javax.swing.JCheckBox();
        cb_Topo_Path_REF = new javax.swing.JCheckBox();
        btn_Topo_Switch = new javax.swing.JButton();
        cb_Topo_Force_DER = new javax.swing.JCheckBox();
        cb_Topo_Segment_DER = new javax.swing.JCheckBox();
        cb_Topo_Segment_REF = new javax.swing.JCheckBox();
        cb_Topo_Segment_SOURCE = new javax.swing.JCheckBox();
        cb_Topo_ParamTopoNode_DER = new javax.swing.JCheckBox();
        cb_Topo_ObjetsSupprimesDER = new javax.swing.JCheckBox();
        cb_Topo_ZoneInfluenceNode_DER = new javax.swing.JCheckBox();
        cb_Topo_DimensionNode_DER = new javax.swing.JCheckBox();
        cb_Topo_ParamTopoNode_REF = new javax.swing.JCheckBox();
        cb_Topo_DimensionNode_REF = new javax.swing.JCheckBox();
        cb_Topo_ZoneInfluenceNode_REF = new javax.swing.JCheckBox();
        cb_Zone = new javax.swing.JCheckBox();

        tabbedPane.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                tabbedPaneStateChanged(evt);
            }
        });

        cb_Papier_Data_DER.setSelected(true);
        cb_Papier_Data_DER.setText("Données généralisées");
        cb_Papier_Data_DER.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cb_Papier_Data_DERActionPerformed(evt);
            }
        });

        cb_Papier_Sites_DER.setSelected(true);
        cb_Papier_Sites_DER.setText("Sites");
        cb_Papier_Sites_DER.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cb_Papier_Sites_DERActionPerformed(evt);
            }
        });

        cb_Papier_Lignes_DER.setSelected(true);
        cb_Papier_Lignes_DER.setText("Lignes");
        cb_Papier_Lignes_DER.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cb_Papier_Lignes_DERActionPerformed(evt);
            }
        });

        cb_Papier_Data_REF.setText("Données d'entrée");
        cb_Papier_Data_REF.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cb_Papier_Data_REFActionPerformed(evt);
            }
        });

        cb_Papier_Sites_REF.setSelected(true);
        cb_Papier_Sites_REF.setText("Sites");
        cb_Papier_Sites_REF.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cb_Papier_Sites_REFActionPerformed(evt);
            }
        });

        cb_Papier_Lignes_REF.setSelected(true);
        cb_Papier_Lignes_REF.setText("Lignes");
        cb_Papier_Lignes_REF.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cb_Papier_Lignes_REFActionPerformed(evt);
            }
        });

        btn_Papier_Switch.setText("Switch REF / GEN");
        btn_Papier_Switch.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_Papier_SwitchActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(cb_Papier_Data_DER)
                    .addComponent(cb_Papier_Data_REF)
                    .addComponent(btn_Papier_Switch)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(21, 21, 21)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(cb_Papier_Lignes_DER)
                            .addComponent(cb_Papier_Sites_DER)
                            .addComponent(cb_Papier_Lignes_REF)
                            .addComponent(cb_Papier_Sites_REF))))
                .addContainerGap(27, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(cb_Papier_Data_DER)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(cb_Papier_Sites_DER)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(cb_Papier_Lignes_DER)
                .addGap(41, 41, 41)
                .addComponent(cb_Papier_Data_REF)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(cb_Papier_Sites_REF)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(cb_Papier_Lignes_REF)
                .addGap(27, 27, 27)
                .addComponent(btn_Papier_Switch)
                .addContainerGap(256, Short.MAX_VALUE))
        );

        tabbedPane.addTab("Papier", jPanel1);

        cb_Topo_Data_DER.setSelected(true);
        cb_Topo_Data_DER.setText("Données généralisées");
        cb_Topo_Data_DER.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cb_Topo_Data_DERActionPerformed(evt);
            }
        });

        cb_Topo_Data_REF.setText("Données d'entrée");
        cb_Topo_Data_REF.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cb_Topo_Data_REFActionPerformed(evt);
            }
        });

        cb_Topo_Junction_DER.setSelected(true);
        cb_Topo_Junction_DER.setText("Jonctions");
        cb_Topo_Junction_DER.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cb_Topo_Junction_DERActionPerformed(evt);
            }
        });

        cb_Topo_Path_DER.setSelected(true);
        cb_Topo_Path_DER.setText("Paths");
        cb_Topo_Path_DER.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cb_Topo_Path_DERActionPerformed(evt);
            }
        });

        cb_Topo_Junction_REF.setSelected(true);
        cb_Topo_Junction_REF.setText("Jonctions");
        cb_Topo_Junction_REF.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cb_Topo_Junction_REFActionPerformed(evt);
            }
        });

        cb_Topo_Path_REF.setSelected(true);
        cb_Topo_Path_REF.setText("Paths");
        cb_Topo_Path_REF.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cb_Topo_Path_REFActionPerformed(evt);
            }
        });

        btn_Topo_Switch.setText("Switch REF / GEN");
        btn_Topo_Switch.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_Topo_SwitchActionPerformed(evt);
            }
        });

        cb_Topo_Force_DER.setText("Forces");
        cb_Topo_Force_DER.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cb_Topo_Force_DERActionPerformed(evt);
            }
        });

        cb_Topo_Segment_DER.setText("Segments");
        cb_Topo_Segment_DER.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cb_Topo_Segment_DERActionPerformed(evt);
            }
        });

        cb_Topo_Segment_REF.setText("Segments (post trt)");
        cb_Topo_Segment_REF.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cb_Topo_Segment_REFActionPerformed(evt);
            }
        });

        cb_Topo_Segment_SOURCE.setText("Segments (source)");
        cb_Topo_Segment_SOURCE.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cb_Topo_Segment_SOURCEActionPerformed(evt);
            }
        });

        cb_Topo_ParamTopoNode_DER.setText("Params topo. node");
        cb_Topo_ParamTopoNode_DER.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cb_Topo_ParamTopoNode_DERActionPerformed(evt);
            }
        });

        cb_Topo_ObjetsSupprimesDER.setText("Objets non généralisés");
        cb_Topo_ObjetsSupprimesDER.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cb_Topo_ObjetsSupprimesDERActionPerformed(evt);
            }
        });

        cb_Topo_ZoneInfluenceNode_DER.setText("Zone influence nodes");
        cb_Topo_ZoneInfluenceNode_DER.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cb_Topo_ZoneInfluenceNode_DERActionPerformed(evt);
            }
        });

        cb_Topo_DimensionNode_DER.setSelected(true);
        cb_Topo_DimensionNode_DER.setText("Dimension nodes");
        cb_Topo_DimensionNode_DER.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cb_Topo_DimensionNode_DERActionPerformed(evt);
            }
        });

        cb_Topo_ParamTopoNode_REF.setText("Params topo. node");
        cb_Topo_ParamTopoNode_REF.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cb_Topo_ParamTopoNode_REFActionPerformed(evt);
            }
        });

        cb_Topo_DimensionNode_REF.setSelected(true);
        cb_Topo_DimensionNode_REF.setText("Dimension nodes");
        cb_Topo_DimensionNode_REF.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cb_Topo_DimensionNode_REFActionPerformed(evt);
            }
        });

        cb_Topo_ZoneInfluenceNode_REF.setText("Zone influence nodes");
        cb_Topo_ZoneInfluenceNode_REF.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cb_Topo_ZoneInfluenceNode_REFActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(cb_Topo_Data_DER)
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(btn_Topo_Switch)
                            .addComponent(cb_Topo_Data_REF)
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addGap(21, 21, 21)
                                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(cb_Topo_Path_DER)
                                    .addComponent(cb_Topo_ObjetsSupprimesDER)
                                    .addComponent(cb_Topo_Junction_DER)
                                    .addComponent(cb_Topo_Force_DER)
                                    .addComponent(cb_Topo_ParamTopoNode_DER)
                                    .addComponent(cb_Topo_Segment_DER)
                                    .addComponent(cb_Topo_DimensionNode_DER)
                                    .addComponent(cb_Topo_Junction_REF)
                                    .addComponent(cb_Topo_Path_REF)
                                    .addComponent(cb_Topo_ZoneInfluenceNode_REF)
                                    .addComponent(cb_Topo_ParamTopoNode_REF)
                                    .addComponent(cb_Topo_DimensionNode_REF)
                                    .addComponent(cb_Topo_Segment_REF)
                                    .addComponent(cb_Topo_Segment_SOURCE)
                                    .addComponent(cb_Topo_ZoneInfluenceNode_DER))))
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(cb_Topo_Data_DER)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(cb_Topo_Force_DER)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(cb_Topo_Junction_DER)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(cb_Topo_Path_DER)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(cb_Topo_ParamTopoNode_DER)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(cb_Topo_DimensionNode_DER)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(cb_Topo_ZoneInfluenceNode_DER)
                .addGap(2, 2, 2)
                .addComponent(cb_Topo_ObjetsSupprimesDER)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(cb_Topo_Segment_DER)
                .addGap(21, 21, 21)
                .addComponent(cb_Topo_Data_REF)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(cb_Topo_Junction_REF)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(cb_Topo_Path_REF)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(cb_Topo_ParamTopoNode_REF)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(cb_Topo_DimensionNode_REF)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(cb_Topo_ZoneInfluenceNode_REF)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(cb_Topo_Segment_REF)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(cb_Topo_Segment_SOURCE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 34, Short.MAX_VALUE)
                .addComponent(btn_Topo_Switch)
                .addContainerGap())
        );

        tabbedPane.addTab("Topo", jPanel3);

        cb_Zone.setSelected(true);
        cb_Zone.setText("Zones");
        cb_Zone.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cb_ZoneActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(tabbedPane)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(cb_Zone)
                        .addGap(0, 0, Short.MAX_VALUE))))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addComponent(tabbedPane, javax.swing.GroupLayout.PREFERRED_SIZE, 520, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(cb_Zone)
                .addContainerGap(25, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents

	private void majGrisageCheckBoxes() {
		if (cb_Topo_Data_REF.isSelected()) {
			cb_Topo_Junction_REF.setEnabled(true);
			cb_Topo_Path_REF.setEnabled(true);
			cb_Topo_ParamTopoNode_REF.setEnabled(true);
			cb_Topo_DimensionNode_REF.setEnabled(true);
			cb_Topo_ZoneInfluenceNode_REF.setEnabled(true);
			cb_Topo_Segment_REF.setEnabled(true);
			cb_Topo_Segment_SOURCE.setEnabled(true);
		} else {
			cb_Topo_Junction_REF.setEnabled(false);
			cb_Topo_Path_REF.setEnabled(false);
			cb_Topo_ParamTopoNode_REF.setEnabled(false);
			cb_Topo_DimensionNode_REF.setEnabled(false);
			cb_Topo_ZoneInfluenceNode_REF.setEnabled(false);
			cb_Topo_Segment_REF.setEnabled(false);
			cb_Topo_Segment_SOURCE.setEnabled(false);
		}

		if (cb_Topo_Data_DER.isSelected()) {
			cb_Topo_Force_DER.setEnabled(true);
			cb_Topo_ParamTopoNode_DER.setEnabled(true);
			cb_Topo_DimensionNode_DER.setEnabled(true);
			cb_Topo_ZoneInfluenceNode_DER.setEnabled(true);
			cb_Topo_Junction_DER.setEnabled(true);
			cb_Topo_Path_DER.setEnabled(true);
			cb_Topo_Segment_DER.setEnabled(true);
			cb_Topo_ParamTopoNode_DER.setEnabled(true);
			cb_Topo_ObjetsSupprimesDER.setEnabled(true);
		} else {
			cb_Topo_Force_DER.setEnabled(false);
			cb_Topo_ParamTopoNode_DER.setEnabled(false);
			cb_Topo_DimensionNode_DER.setEnabled(false);
			cb_Topo_ZoneInfluenceNode_DER.setEnabled(false);
			cb_Topo_Junction_DER.setEnabled(false);
			cb_Topo_Path_DER.setEnabled(false);
			cb_Topo_Segment_DER.setEnabled(false);
			cb_Topo_ParamTopoNode_DER.setEnabled(false);
			cb_Topo_ObjetsSupprimesDER.setEnabled(false);
		}


		if (cb_Papier_Data_DER.isSelected()) {
			cb_Papier_Sites_DER.setEnabled(true);
			cb_Papier_Lignes_DER.setEnabled(true);
		} else {
			cb_Papier_Sites_DER.setEnabled(false);
			cb_Papier_Lignes_DER.setEnabled(false);
		}

		if (cb_Papier_Data_REF.isSelected()) {
			cb_Papier_Sites_REF.setEnabled(true);
			cb_Papier_Lignes_REF.setEnabled(true);
		} else {
			cb_Papier_Sites_REF.setEnabled(false);
			cb_Papier_Lignes_REF.setEnabled(false);
		}

	}

	private void cb_Topo_Data_REFActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cb_Topo_Data_REFActionPerformed
		majGrisageCheckBoxes();
		changeInSelectedCouche();
}//GEN-LAST:event_cb_Topo_Data_REFActionPerformed

	private void cb_Topo_Data_DERActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cb_Topo_Data_DERActionPerformed
		majGrisageCheckBoxes();
		changeInSelectedCouche();
	}//GEN-LAST:event_cb_Topo_Data_DERActionPerformed

	private void tabbedPaneStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_tabbedPaneStateChanged
		// changement éventuel de mode d'affichage : on redessine tout
		panel_Pere.clearSelectionAndHighlight();
		changeInSelectedCouche();
	}//GEN-LAST:event_tabbedPaneStateChanged

	private void cb_Topo_Path_DERActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cb_Topo_Path_DERActionPerformed
		changeInSelectedCouche();
	}//GEN-LAST:event_cb_Topo_Path_DERActionPerformed

	private void cb_Topo_Junction_DERActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cb_Topo_Junction_DERActionPerformed
		changeInSelectedCouche();
	}//GEN-LAST:event_cb_Topo_Junction_DERActionPerformed

	private void cb_Topo_Junction_REFActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cb_Topo_Junction_REFActionPerformed
		changeInSelectedCouche();
	}//GEN-LAST:event_cb_Topo_Junction_REFActionPerformed

	private void cb_Topo_Path_REFActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cb_Topo_Path_REFActionPerformed
		changeInSelectedCouche();
	}//GEN-LAST:event_cb_Topo_Path_REFActionPerformed

	private void cb_Papier_Data_DERActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cb_Papier_Data_DERActionPerformed
		majGrisageCheckBoxes();
		changeInSelectedCouche();
	}//GEN-LAST:event_cb_Papier_Data_DERActionPerformed

	private void cb_Papier_Data_REFActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cb_Papier_Data_REFActionPerformed
		majGrisageCheckBoxes();
		changeInSelectedCouche();
	}//GEN-LAST:event_cb_Papier_Data_REFActionPerformed

	private void cb_Papier_Sites_DERActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cb_Papier_Sites_DERActionPerformed
		changeInSelectedCouche();
	}//GEN-LAST:event_cb_Papier_Sites_DERActionPerformed

	private void cb_Papier_Lignes_DERActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cb_Papier_Lignes_DERActionPerformed
		changeInSelectedCouche();
	}//GEN-LAST:event_cb_Papier_Lignes_DERActionPerformed

	private void cb_Papier_Sites_REFActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cb_Papier_Sites_REFActionPerformed
		changeInSelectedCouche();
	}//GEN-LAST:event_cb_Papier_Sites_REFActionPerformed

	private void cb_Papier_Lignes_REFActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cb_Papier_Lignes_REFActionPerformed
		changeInSelectedCouche();
	}//GEN-LAST:event_cb_Papier_Lignes_REFActionPerformed

	private void btn_Papier_SwitchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_Papier_SwitchActionPerformed
		if (cb_Papier_Data_DER.isSelected() ==  cb_Papier_Data_REF.isSelected()) {
			// Les 2 cb principales sont cochées ou décochées simultanément
			// on repasse au DER
			cb_Papier_Data_DER.setSelected(true);
			cb_Papier_Data_REF.setSelected(false);
		} else {
			// Sinon, on alterne
			if (cb_Papier_Data_DER.isSelected()) {
				cb_Papier_Data_DER.setSelected(false);
				cb_Papier_Data_REF.setSelected(true);
			} else {
				cb_Papier_Data_DER.setSelected(true);
				cb_Papier_Data_REF.setSelected(false);
			}
		}
		majGrisageCheckBoxes();
		changeInSelectedCouche();
}//GEN-LAST:event_btn_Papier_SwitchActionPerformed

	private void btn_Topo_SwitchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_Topo_SwitchActionPerformed
		if (cb_Topo_Data_DER.isSelected() ==  cb_Topo_Data_REF.isSelected()) {
			// Les 2 cb principales sont cochées ou décochées simultanément
			// on repasse au DER
			cb_Topo_Data_DER.setSelected(true);
			cb_Topo_Data_REF.setSelected(false);
		} else {
			// Sinon, on alterne
			if (cb_Topo_Data_DER.isSelected()) {
				cb_Topo_Data_DER.setSelected(false);
				cb_Topo_Data_REF.setSelected(true);
			} else {
				cb_Topo_Data_DER.setSelected(true);
				cb_Topo_Data_REF.setSelected(false);
			}
		}
		majGrisageCheckBoxes();
		changeInSelectedCouche();
	}//GEN-LAST:event_btn_Topo_SwitchActionPerformed

	private void cb_Topo_Force_DERActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cb_Topo_Force_DERActionPerformed
		changeInSelectedCouche();
	}//GEN-LAST:event_cb_Topo_Force_DERActionPerformed

	private void cb_Topo_Segment_DERActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cb_Topo_Segment_DERActionPerformed
		changeInSelectedCouche();
	}//GEN-LAST:event_cb_Topo_Segment_DERActionPerformed

	private void cb_ZoneActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cb_ZoneActionPerformed
		changeInSelectedCouche();
	}//GEN-LAST:event_cb_ZoneActionPerformed

	private void cb_Topo_Segment_REFActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cb_Topo_Segment_REFActionPerformed
		changeInSelectedCouche();
	}//GEN-LAST:event_cb_Topo_Segment_REFActionPerformed

	private void cb_Topo_Segment_SOURCEActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cb_Topo_Segment_SOURCEActionPerformed
		changeInSelectedCouche();
	}//GEN-LAST:event_cb_Topo_Segment_SOURCEActionPerformed

	private void cb_Topo_ParamTopoNode_DERActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cb_Topo_ParamTopoNode_DERActionPerformed
		changeInSelectedCouche();
	}//GEN-LAST:event_cb_Topo_ParamTopoNode_DERActionPerformed

	private void cb_Topo_ObjetsSupprimesDERActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cb_Topo_ObjetsSupprimesDERActionPerformed
		changeInSelectedCouche();
	}//GEN-LAST:event_cb_Topo_ObjetsSupprimesDERActionPerformed

    private void cb_Topo_ZoneInfluenceNode_DERActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cb_Topo_ZoneInfluenceNode_DERActionPerformed
        changeInSelectedCouche();
    }//GEN-LAST:event_cb_Topo_ZoneInfluenceNode_DERActionPerformed

    private void cb_Topo_DimensionNode_DERActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cb_Topo_DimensionNode_DERActionPerformed
        changeInSelectedCouche();
    }//GEN-LAST:event_cb_Topo_DimensionNode_DERActionPerformed

    private void cb_Topo_ParamTopoNode_REFActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cb_Topo_ParamTopoNode_REFActionPerformed
        changeInSelectedCouche();
    }//GEN-LAST:event_cb_Topo_ParamTopoNode_REFActionPerformed

    private void cb_Topo_DimensionNode_REFActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cb_Topo_DimensionNode_REFActionPerformed
        changeInSelectedCouche();
    }//GEN-LAST:event_cb_Topo_DimensionNode_REFActionPerformed

    private void cb_Topo_ZoneInfluenceNode_REFActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cb_Topo_ZoneInfluenceNode_REFActionPerformed
        changeInSelectedCouche();
    }//GEN-LAST:event_cb_Topo_ZoneInfluenceNode_REFActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btn_Papier_Switch;
    private javax.swing.JButton btn_Topo_Switch;
    private javax.swing.JCheckBox cb_Papier_Data_DER;
    private javax.swing.JCheckBox cb_Papier_Data_REF;
    private javax.swing.JCheckBox cb_Papier_Lignes_DER;
    private javax.swing.JCheckBox cb_Papier_Lignes_REF;
    private javax.swing.JCheckBox cb_Papier_Sites_DER;
    private javax.swing.JCheckBox cb_Papier_Sites_REF;
    private javax.swing.JCheckBox cb_Topo_Data_DER;
    private javax.swing.JCheckBox cb_Topo_Data_REF;
    private javax.swing.JCheckBox cb_Topo_DimensionNode_DER;
    private javax.swing.JCheckBox cb_Topo_DimensionNode_REF;
    private javax.swing.JCheckBox cb_Topo_Force_DER;
    private javax.swing.JCheckBox cb_Topo_Junction_DER;
    private javax.swing.JCheckBox cb_Topo_Junction_REF;
    private javax.swing.JCheckBox cb_Topo_ObjetsSupprimesDER;
    private javax.swing.JCheckBox cb_Topo_ParamTopoNode_DER;
    private javax.swing.JCheckBox cb_Topo_ParamTopoNode_REF;
    private javax.swing.JCheckBox cb_Topo_Path_DER;
    private javax.swing.JCheckBox cb_Topo_Path_REF;
    private javax.swing.JCheckBox cb_Topo_Segment_DER;
    private javax.swing.JCheckBox cb_Topo_Segment_REF;
    private javax.swing.JCheckBox cb_Topo_Segment_SOURCE;
    private javax.swing.JCheckBox cb_Topo_ZoneInfluenceNode_DER;
    private javax.swing.JCheckBox cb_Topo_ZoneInfluenceNode_REF;
    private javax.swing.JCheckBox cb_Zone;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JTabbedPane tabbedPane;
    // End of variables declaration//GEN-END:variables


}
